const day97 = Array.from({ length: 97 }, (v, i) => {
  let hh = Math.floor(i / 4);
  let mm = 15 * (i % 4) || '00';
  hh = hh < 10 ? '0' + hh : hh;
  return `${hh}:${mm}`;
});
const day96 = day97.slice(1);

export const getXData = (t) => {
  const now = new Date();
  const year = now.getFullYear() + '';
  const month = now.getMonth() + 1 + '';
  const days = new Date(year, month, 0).getDate();
  switch (t) {
    case '97':
      // ['00:00', '00:15',... '24:00'] 单日15分钟间隔97个点位
      return [...day97];
    case '96':
      // ['00:15',... '24:00'] 单日15分钟间隔96个点位
      return [...day96];
    case 'days':
      // 当前月的天
      return Array.from(
        { length: days },
        (v, i) => `${month.padStart(2, '0')}.${String(i + 1).padStart(2, '0')}`,
      );
    case 'months':
      // 12个月
      const year = now.getFullYear() + '';
      return Array.from(
        { length: 12 },
        (v, i) => `${year.padStart(2, '0')}.${String(i + 1).padStart(2, '0')}`,
      );
    default:
      return [];
  }
};

export function getPreIdx() {
  // 计算当前时间的
  const now = new Date();
  const hour = now.getHours();
  const min = now.getMinutes();
  if (hour === 0) {
    if (min < 15) {
      return 95;
    } else if (min < 30) {
      return 0;
    } else if (min < 45) {
      return 1;
    } else {
      return 2;
    }
  } else {
    if (min < 15) {
      return hour * 4 - 1;
    } else if (min < 30) {
      return hour * 4;
    } else if (min < 45) {
      return hour * 4 + 1;
    } else if (min < 60) {
      return hour * 4 + 2;
    }
  }
}

export const xAxis = {
  type: 'category',
  boundaryGap: false,
  nameGap: 15,
  axisTick: { lineStyle: { color: '#D1D9E9' } },
  axisLabel: { color: '#888E95', showMaxLabel: true },
  axisLine: { lineStyle: { color: '#5A5A5A' } },
};

export const yAxis = {
  type: 'value',
  nameGap: 12,
  axisTick: { show: false },
  axisLabel: { color: '#888E95' },
  splitLine: { lineStyle: { color: 'rgba(90, 90, 90, 0.4)' } },
};
